package com.anyisn.anyflickr.modules.PhotoInfo.view.component
{
	import com.adobe.webapis.flickr.Photo;
	
	import flash.display.Bitmap;
	
	import mx.core.UIComponent;
	import mx.core.Window;
	import mx.effects.Resize;
	
	public class PhotoInfoWindow extends Window
	{
		public static const GET_SIZES:String = 'getSizes';
		public static const SHOW_MENU:String = 'showMenu';
		public var moduleID:String;// for main application to remove the right module mediator when module window was closed
		
		public function PhotoInfoWindow(bitmap:Bitmap, photo:Photo)
		{
			super();
			this.showGripper = false;
			this.showStatusBar = false;
			this.maximizable = false;
			this.resizable = false;
			this.layout = "absolute";
			this.horizontalScrollPolicy = "off";
			this.verticalScrollPolicy = "off";
			
			resize = new Resize(this);
			resize.duration = 500;
			showPhoto(bitmap, photo);
//			open();
		}
		
		/*private function showMenu(e:MouseEvent):void {
			dispatchEvent(new Event(SHOW_MENU));
		}*/
		
		public function showPhoto(bitmap:Bitmap, photo:Photo):void {
			_photo = photo;
			this.title = photo.title.substring(0,30);
			bitmap.x = 0;
			bitmap.y = 0;
			var ui:UIComponent = new UIComponent();
			ui.x = 0;
			ui.y = 0;
			ui.height = bitmap.height;
			ui.width = bitmap.width;
			//ui.addEventListener(MouseEvent.RIGHT_CLICK, showMenu);
			ui.addChild(bitmap);
			removeAllChildren();
			this.addChild(ui);
			
			resize.end();
			resize.widthTo = ui.width;
			resize.heightTo = ui.height;
			resize.play();
		}
		
		public function get photo():Photo {
			return _photo;
		}
		
		private var _photo:Photo;
		private var resize:Resize;
	}
}